import requests
from config import BASE_URL, TOKEN, EMPID


class IMRML:

    @classmethod
    def add_urst(cls, data):
        add_url = BASE_URL + '/api/sys/user'

        headers = {
            "Content-Type": "application/json",
            "Authorization": TOKEN
        }

        r = requests.post(add_url, headers=headers, json=data)
        return r

    @classmethod
    def delete_urst(cls):
        add_url = BASE_URL + '/api/sys/user/'+ EMPID

        headers = {
            "Authorization": TOKEN
        }

        r = requests.delete(add_url, headers=headers)
        return r

    @classmethod
    def delete_urst2(cls, empid):
        add_url = BASE_URL + '/api/sys/user/' + empid

        headers = {
            "Authorization": TOKEN
        }

        r = requests.delete(add_url, headers=headers)
        return r

    @classmethod
    def update_urst(cls, data):
        add_url = BASE_URL + '/api/sys/user/' + EMPID

        headers = {
            "Content-Type": "application/json",
            "Authorization": TOKEN
        }

        r = requests.put(add_url, headers=headers, json=data)
        return r

    @classmethod
    def get_urst(cls):
        add_url = BASE_URL + '/api/sys/user?page=1&size=10'

        headers = {
            "Authorization": TOKEN
        }

        r = requests.get(add_url, headers=headers)
        return r


# if __name__ == '__main__':
#     aa = IMRML.delete_urst()
#     print(aa.status_code)
#     print(aa.json())

#     # data = {
#     #     "username": "李四"
#     # }
#     #
#     # cc = IMRML.update_urst(data)
#     # print(cc.status_code)
#     # print(cc.json())
#
#     # kk = IMRML.get_urst()
#     # print(kk.status_code)
#     # print(kk.json())
#
#     data = {
#         "username": "张三",
#         "mobile": "15076715313",
#         "workNumber": "9527"
#     }
#     ss = IMRML.add_urst(data)
#     print(ss.status_code)
#     print(ss.json())

